package main

import (
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	path := "tmp"
	rename(path)
	listName(path)
}

func listName(path string) {
	infos, err := ioutil.ReadDir(path)
	if err != nil {
		fmt.Println(err)
		return
	}
	for _, info := range infos {
		fmt.Println(info.Name())
	}
}

func rename(path string) {
	infos, err := ioutil.ReadDir(path)
	if err != nil {
		fmt.Println(err)
		return
	}
	for _, info := range infos {
		oldPath := path + "/" + info.Name()
		os.Rename(oldPath, oldPath+".txt")
	}
}
